<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
          <a-col :span="24">
            <a-form-model-item label="版本号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="version">
              <a-input-number v-model="model.version" placeholder="请输入版本号" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="是否删除" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="deleted">
              <a-input-number v-model="model.deleted" placeholder="请输入是否删除" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="管点名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="pipName">
              <a-input v-model="model.pipName" placeholder="请输入管点名称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="管点编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="pipNo">
              <a-input v-model="model.pipNo" placeholder="请输入管点编号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="管点类型 1雨水井 2污水井" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="pipType">
              <a-input-number v-model="model.pipType" placeholder="请输入管点类型 1雨水井 2污水井" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="关联点位编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="associationPosPointNo">
              <a-input v-model="model.associationPosPointNo" placeholder="请输入关联点位编号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="地面高程" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dsm">
              <a-input v-model="model.dsm" placeholder="请输入地面高程"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="ArcGis编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="arcgis">
              <a-input v-model="model.arcgis" placeholder="请输入ArcGis编号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="经度" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="longitude">
              <a-input-number v-model="model.longitude" placeholder="请输入经度" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="纬度" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="latitude">
              <a-input-number v-model="model.latitude" placeholder="请输入纬度" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="物探经度" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="geophysicaLongitude">
              <a-input-number v-model="model.geophysicaLongitude" placeholder="请输入物探经度" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="物探纬度" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="geophysicaLatitude">
              <a-input-number v-model="model.geophysicaLatitude" placeholder="请输入物探纬度" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="备注" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="remark">
              <a-input v-model="model.remark" placeholder="请输入备注"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="status">
              <a-input-number v-model="model.status" placeholder="请输入状态" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="所属区域" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="areaName">
              <a-input v-model="model.areaName" placeholder="请输入所属区域"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="所属区域id" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="areaId">
              <a-input v-model="model.areaId" placeholder="请输入所属区域id"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="关联点位id" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="associationPosPoint">
              <a-input v-model="model.associationPosPoint" placeholder="请输入关联点位id"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="道路" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="street">
              <a-input v-model="model.street" placeholder="请输入道路"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="地址" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="address">
              <a-input v-model="model.address" placeholder="请输入地址"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="井深" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="measureDepth">
              <a-input v-model="model.measureDepth" placeholder="请输入井深"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="是否终端" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="isTerminal">
              <a-input-number v-model="model.isTerminal" placeholder="请输入是否终端" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="管点缺陷" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="pipPointDefective">
              <a-input-number v-model="model.pipPointDefective" placeholder="请输入管点缺陷" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="null" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="manageScope">
              <a-input v-model="model.manageScope" placeholder="请输入null"  ></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>

  import { httpAction, getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'

  export default {
    name: 'PipLineTempForm',
    components: {
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        model:{
         },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
           pipName: [
              { required: true, message: '请输入管点名称!'},
           ],
           associationPosPointNo: [
              { required: true, message: '请输入关联点位编号!'},
           ],
        },
        url: {
          add: "/ps/pipLineTemp/add",
          edit: "/ps/pipLineTemp/edit",
          queryById: "/ps/pipLineTemp/queryById"
        }
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
            })
          }
         
        })
      },
    }
  }
</script>